﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class CompanyCard : UserControl
    {
        private CompanyMatzalPanel cMatzalPanel;
        private CompanyPakalPanel cPakalPanel;
        private CompanyGearPanel cGearPanel;
        private CompanyTahasukaAbilityPanel cTahasukaAbilityPanel;
        private CompanyWarAbilityPanel cWarAbilityPanel;
        private CompanyMainPanel companyMainPanel;

        public CompanyCard()
        {
            InitializeComponent();
                       
            cMatzalPanel = new CompanyMatzalPanel(this);
            cPakalPanel = new CompanyPakalPanel(this);
            cGearPanel = new CompanyGearPanel(this);
            cTahasukaAbilityPanel = new CompanyTahasukaAbilityPanel(this);
            cWarAbilityPanel = new CompanyWarAbilityPanel(this);

            changeMainPanel(companyMainPanel);

            this.Dock = DockStyle.Fill;
        }

        private void buttonMain_Click(object sender, EventArgs e)
        {
            changeMainPanel(companyMainPanel);
            textBoxTopBar.Text = "כרטיס פלוגה - מסך ראשי";
        }

        private void buttonWarCapability_Click(object sender, EventArgs e)
        {
            changeMainPanel(cWarAbilityPanel);
            textBoxTopBar.Text = "כרטיס פלוגה - כשירויות מלחמה";
        }

        private void buttonTahasukaCapability_Click(object sender, EventArgs e)
        {
            changeMainPanel(cTahasukaAbilityPanel);
            textBoxTopBar.Text = "כרטיס פלוגה - כשירויות תעסוקה";
        }

        private void buttonEquipment_Click(object sender, EventArgs e)
        {
            changeMainPanel(cGearPanel);
            textBoxTopBar.Text = "כרטיס פלוגה - ציוד";
        }

    
        private void buttonMatzal_Click(object sender, EventArgs e)
        {
            changeMainPanel(cMatzalPanel);
            textBoxTopBar.Text = "כרטיס פלוגה - מצ''ל";
        }

        private void buttonPakalim_Click(object sender, EventArgs e)
        {
            changeMainPanel(cPakalPanel);
            textBoxTopBar.Text = "כרטיס פלוגה - מסך ראשי";
        }

        private void changeMainPanel(Control ctrl)
        {
            if (!panel2.Controls.Contains(ctrl))
            {
                if (ctrl.GetType().Equals(cGearPanel.GetType()))
                    cGearPanel.refresh();

                panel2.Controls.Clear();
                panel2.Controls.Add(ctrl);
            }

        }
        public void refresh()
        {
            if (this.Visible)
                cMatzalPanel.refresh();
        }

    }
}
